<template>
  <div class="blog-preview">
    <h2>{{blog.title}}</h2>
    <div class="information">{{blog.type}}&nbsp;&nbsp;&nbsp;&nbsp;{{blog.timestamp}}</div>
    <div class="line"></div>
    <div class="description">{{blog.description}}</div>
    <el-image :src="blog.url"></el-image>
    <div class="more">
        <el-button type="primary" plain @click="toDtail">阅读全文</el-button>
    </div>
  </div>
</template>

<script>
import router from '@/router'

export default {
    name: 'BlogPreview',
    props: ['blog'],
    setup(props) {
        const toDtail = () => {
            router.push(`/blog/${props.blog.id}`)
        }

        return {
            toDtail
        }
    }
}
</script>

<style scoped>
    .blog-preview {
        width: 50vw;
        margin: 0 auto;
        margin-bottom: 50px;
        padding: 20px;
        box-sizing: border-box;
        box-shadow: var(--el-box-shadow-light);
        overflow: hidden;
    }
    h2, .information {
        text-align: center;
        margin: 5px 0;
    }
    .information {
        font-size: 12px;
    }
    .line {
        height: 1px;
        margin: 10px 0;
        background-color: #E4E7ED;
    }
    .el-image {
        margin: 10px 0;
    }
    .more {
        display: flex;
        justify-content: center;
    }
</style>